package com.sy.api;

/**
 * @className: ChaptersController
 * @author: Mr.Liu
 * @date: 2025/10/29 14:37
 * @Version: 1.0
 * @description:
 */

import com.sy.ResultVO;
import com.sy.pojo.CourseTypes;
import com.sy.pojo.Courses;
import com.sy.service.ChaptersService;
import com.sy.service.CourseTypesService;
import com.sy.service.CoursesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api/chapters")
@Tag(name = "章节管理模块")
@Slf4j
public class ChaptersController {
    @Resource
    private CoursesService coursesService;
    @Resource
    private ChaptersService chaptersService;
    @PostMapping("/add")
    @Operation(summary = "添加章节")
    public ResultVO<Object> add(@RequestBody Courses courses) {
        log.info("增加章节的入参:{}",courses);
        coursesService.insertCourses(courses);
        return ResultVO.success();

    }
    @DeleteMapping("/{id}")
    @Operation(summary = "删除章节")
    public ResultVO<Object> del(@PathVariable Integer id) {
        log.info("删除章节的入参ID:{}",id);
        boolean flag = chaptersService.removeById(id);
        return flag?ResultVO.success():ResultVO.error();

    }

}
